﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Simple.Services;
namespace Simple.WebApi.Controllers.System;

/// <summary>
/// 隐患关键作业
/// </summary>
[Route("QHSEDangerKeyWork/[action]")]
[ApiController]
public class QHSEDangerKeyWorkController : ControllerBase
{
    private readonly DangerKeyWorkAnalysisService _dangerKeyWorkAnalysisService;

    public QHSEDangerKeyWorkController(DangerKeyWorkAnalysisService dangerKeyWorkAnalysisService)
    {
        _dangerKeyWorkAnalysisService = dangerKeyWorkAnalysisService;
    }
    /// <summary>
    /// 关键作业分析--关键作业
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_d_gjzy_analysis")]
    public async Task<AppResult> KeyWorkAnalysis([FromBody] DangerKeyWorkInput input)
    {
        var res = await _dangerKeyWorkAnalysisService.KeyWorkAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 关键作业分析--隐患级别
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_d_gjzy_analysis")]
    public async Task<AppResult> DangerTypeAnalysis([FromBody] DangerKeyWorkInput input)
    {
        var res = await _dangerKeyWorkAnalysisService.DangerTypeAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 关键作业分析--整改情况
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_d_gjzy_analysis")]
    public async Task<AppResult> DangerStatusAnalysis([FromBody] DangerKeyWorkInput input)
    {
        var res = await _dangerKeyWorkAnalysisService.DangerStatusAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 关键作业分析--物的不安全状态/环境不良
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_d_gjzy_analysis")]
    public async Task<AppResult> UnsafeFactorsAnalysis([FromBody] DangerKeyWorkInput input)
    {
        var res = await _dangerKeyWorkAnalysisService.DangerCategoryAnalysisAsync(input, "不安全因素");
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 关键作业分析--物的不安全状态
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_d_gjzy_analysis")]
    public async Task<AppResult> UnsafeBehaviorAnalysis([FromBody] DangerKeyWorkInput input)
    {
        var res = await _dangerKeyWorkAnalysisService.DangerCategoryAnalysisAsync(input, "物的不安全状态");
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 关键作业分析--环境不良
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_d_gjzy_analysis")]
    public async Task<AppResult> ManagementDeficienciesAnalysis([FromBody] DangerKeyWorkInput input)
    {
        var res = await _dangerKeyWorkAnalysisService.DangerCategoryAnalysisAsync(input, "环境不良");
        return AppResult.Status200OK(data: res);
    }
}

